
var ExamMy = {
		
	popup: function (e, p2, id, status) {
		$.cookie('id_', id);

		p2 = query(p2);
		$.cookie('p2', p2);

		var c1 = 'exam.php?do=Exam.edit&id=' + id;
		var c2 = 'exam.php?do=ExamQuestion.view&id=' + id;
		
		var a1 = ['编辑信息', 'url', 'ExamMy.dialog_edit_', '600x400', '编辑信息'];	
		var a2 = ['查看信息', 'url', 'Common.dialog_view_', '600x400', '查看信息'];
		
		var s = c2;

		return popup(e, [a2], s);
	},

	dialog_answer: function (url, title, xy) {
		$('#dialog_edit').dialog('option', 'buttons', {	
			"交卷": function() {			
				if (!confirm("确认是否提交？")) {
					return false;
				}
				
				ExamMy.answer(3);				
			},
			
			"保存": function() {
				if (!confirm("确认是否提交？")) {
					return false;
				}				
				
				ExamMy.answer(2);
			}
		});
	
		dialog_edit(url, title, xy);
	},
	
	answer: function(status) {
		var result = Common.result();
		var form = $("#form_edit")[0];
		
		var q = $('#form_edit :checkbox').fieldSerialize();
		
		var a = [];
		$("#form_edit :radio").each(function() {					
			var v = $(this).val();
			if ($(this).attr("checked")) {
				a.push({name: this.name, value: v});
			}
		});
		
		$("#form_edit :text").each(function() {					
			var v = $(this).val();
			
			a.push({name: this.name, value: v});
		});
		
		$("#form_edit textarea").each(function() {					
			var v = $(this).val();
			
			a.push({name: this.name, value: v});
		});		
						
		var body = {};
		body.id = form.id.value;
		body.exam = form.exam.value;
		body.answer = a;
		body.status = status;
		
		// alert($.toJSON(body));
						
		$('#dialog_edit').dialog("close");
			
		var url = 'resume.php?do=ExamMy.editPost&' + q;	
		$.post(url, body, function(data) {
			// alert("提交成功！");
			$(result).html(data);
		});
	}
};
